home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_b / ramxe.asm < prev    next >
Assembly Source File  |  1995-04-22  |  6KB  |  194 lines

  1.  
  2. 00010 *"D:RAMXE.ASM 
  3. 00020          .LI OFF 
  4. 00030 *-------------------------------- 
  5. 00040 * Copyright 1985 by Daniel L. Moore 
  6. 00050 * This program may not be sold, 
  7. 00060 * but it may be freely copied and 
  8. 00070 * distributed. 
  9. 00080 *-------------------------------- 
  10. 00090 * Last modified 04/16/85 
  11. 00100 *-------------------------------- 
  12. 00110 * Allow usage of extra RAM in 
  13. 00120 * 130XE computers from BASIC. 
  14. 00130 * There are 2 USR routines: 
  15. 00140 *   The first routine checks if 
  16. 00150 * the machine is a 130XE; 
  17. 00160 *   The second moves blocks of 
  18. 00170 * memory to and from the additional 
  19. 00180 * 64K of banked RAM in the 130XE. 
  20. 00190 *-------------------------------- 
  21. 00200 *  Hardware Equates 
  22. 00210 * 
  23. 00220 PORTB    .EQ $D301 
  24. 00230 * 
  25. 00240 *  Page 0 RAM for pointers 
  26. 00250 * 
  27. 00260 SOURCE   .EQ $D4    FP register 0 
  28. 00270 SOURCE.BNK           .EQ $D6 
  29. 00280 DEST     .EQ $D8 
  30. 00290 DEST.BNK .EQ $DA 
  31. 00300 LENGTH   .EQ $DC 
  32. 00310 *-------------------------------- 
  33. 00320 * Place the code on Page 6, where 
  34. 00330 * BASIC won't overwrite it. 
  35. 00340 * 
  36. 00350          .OR $600 
  37. 00360 * 
  38. 00370          .TF "D:RAMXE.OBJ 
  39. 00380 *-------------------------------- 
  40. 00390 * In both routines, the value 
  41. 00400 * returned indicates success or 
  42. 00410 * failure of the requested function. 
  43. 00420 * If the USR routine was successfull, 
  44. 00430 * a 0 will be returned. Otherwise 
  45. 00440 * the result will be non-zero. 
  46. 00450 *-------------------------------- 
  47. 00460 * This routine is callable from 
  48. 00470 * BASIC.  Use the statement: 
  49. 00480 *   A=USR(1536) 
  50. 00490 * to check if the machine is a 
  51. 00500 * 130XE. A 0 result means a 130XE 
  52. 00510 * any other value is not a 130XE. 
  53. 00520 * 
  54. 00530 CHECK.XE 
  55. 00540          PLA      parameter count from BASIC 
  56. 00550          BNE BAD.PARAMETERS 
  57. 00560 * Check if banked RAM is present 
  58. 00570          LDX $4000 
  59. 00580          LDA XE.BANKS+1 
  60. 00590          STA PORTB   bank #1 
  61. 00600          DEX  
  62. 00610          STX $4000 
  63. 00620          LDA XE.BANKS 
  64. 00630          STA PORTB   normal RAM 
  65. 00640          CPX $4000 
  66. 00650          BNE GOOD.EXIT 
  67. 00660          BEQ EXIT.1 
  68. 00670 *-------------------------------- 
  69. 00680 * Incorrect number of parameters 
  70. 00690 * passed to the routine, clean up 
  71. 00700 * the stack and then exit. 
  72. 00710 BAD.PARAMETERS 
  73. 00720          TAY  
  74. 00730          BEQ .2 
  75. 00740 .1       PLA     drop 2 bytes 
  76. 00750          PLA  
  77. 00760          DEY  
  78. 00770          BNE .1  done? 
  79. 00780 .2       LDA #$FF 
  80. 00790          BNE EXIT.1 
  81. 00800 *-------------------------------- 
  82. 00810 * The following routine moves 
  83. 00820 * blocks of memory to and from the 
  84. 00830 * the banked RAM in the 130XE. 
  85. 00840 * 
  86. 00850 * To call this routine from BASIC: 
  87. 00860 *   A=USR(1577,<source address>,<source bank>, 
  88. 00870 *     <dest address>,<dest bank>,<length) 
  89. 00880 * 
  90. 00890 * The 130XE banks the middle 16K 
  91. 00900 * of RAM. There are actually 5 
  92. 00910 * banks available, numbered 0 to 
  93. 00920 * 4. Bank 0 is the "normal" RAM 
  94. 00930 * that is present when the 130XE 
  95. 00940 * is turned on. Banks 1 to 4 are 
  96. 00950 * the additional 64K of memory 
  97. 00960 * that is present in the machine. 
  98. 00970 * Each bank is 16K (16384) bytes 
  99. 00980 * long. 
  100. 00990 * 
  101. 01000 * Upon entry, the top of stack is 
  102. 01010 * the number of parameters, the 
  103. 01020 * next byte is the HIGH part 
  104. 01030 * of the parameter, the next byte 
  105. 01040 * is the LOW byte of parameter. 
  106. 01050 * NOTE: This routine assumes the 
  107. 01060 * source and destination blocks 
  108. 01070 * do not overlap. If they do, then 
  109. 01080 * all bytes from the start of the 
  110. 01090 * overlap to the end will be set 
  111. 01100 * to the same value. 
  112. 01110 * 
  113. 01120 MOVEBLOCK 
  114. 01130          PLA      parameter count 
  115. 01140          CMP #5   5 parameters? 
  116. 01150          BNE BAD.PARAMETERS 
  117. 01160 * Get 10 bytes from the stack. 
  118. 01170          LDY #0 
  119. 01180 .0       PLA       get high byte 
  120. 01190          STA SOURCE+1,Y 
  121. 01200          PLA       get low byte 
  122. 01210          STA SOURCE,Y 
  123. 01220          INY  
  124. 01230          INY  
  125. 01240          CPY #10 
  126. 01250          BNE .0 
  127. 01260 * Get the values for PORTB for 
  128. 01270 * the banks. 
  129. 01280          LDA #$FF 
  130. 01290          LDY SOURCE.BNK 
  131. 01300          CPY #5 
  132. 01310          BGE EXIT.1 
  133. 01320          LDA XE.BANKS,Y 
  134. 01330          STA SOURCE.BNK 
  135. 01340          LDY DEST.BNK 
  136. 01350          CPY #5 
  137. 01360          BGE EXIT.1 
  138. 01370          LDA XE.BANKS,Y 
  139. 01380          STA DEST.BNK 
  140. 01390 * 
  141. 01400          LDY #0 
  142. 01410 * Check for partial page move 
  143. 01420          LDA LENGTH+1 
  144. 01430          BEQ .2 
  145. 01440 * Move LENGTH+1 full pages 
  146. 01450 .1       LDX SOURCE.BNK 
  147. 01460          STX PORTB 
  148. 01470          LDA (SOURCE),Y 
  149. 01480          LDX DEST.BNK 
  150. 01490          STX PORTB 
  151. 01500          STA (DEST),Y 
  152. 01510          INY  
  153. 01520          BNE .1 
  154. 01530          INC SOURCE+1 
  155. 01540          INC DEST+1 
  156. 01550          DEC LENGTH+1 
  157. 01560          BNE .1 
  158. 01570 * Move the last partial page 
  159. 01580 .2       LDA LENGTH 
  160. 01590          BEQ GOOD.EXIT 
  161. 01600 .21      LDX SOURCE.BNK 
  162. 01610          STX PORTB 
  163. 01620          LDA (SOURCE),Y 
  164. 01630          LDX DEST.BNK 
  165. 01640          STX PORTB 
  166. 01650          STA (DEST),Y 
  167. 01660          INY  
  168. 01670          DEC LENGTH 
  169. 01680          BNE .21 
  170. 01690 * Done, restore OS, and exit 
  171. 01700 GOOD.EXIT 
  172. 01710          LDA #0 
  173. 01720 EXIT.1   STA SOURCE 
  174. 01730          STA SOURCE+1 
  175. 01740 * Reset to normal RAM 
  176. 01750          LDX XE.BANKS 
  177. 01760          STX PORTB 
  178. 01770          RTS  
  179. 01780 *-------------------------------- 
  180. 01790 * XE.BANKS is a table of values 
  181. 01800 * that PORTB should be set to for 
  182. 01810 * each bank.  VBE is not cleared, 
  183. 01820 * so all ANTIC functions will 
  184. 01830 * continue to work from the 
  185. 01840 * main 64K, not the extra 64K. 
  186. 01850 * 
  187. 01860 XE.BANKS .HS FDE1E5E9ED 
  188. 01870 *-------------------------------- 
  189. 01880 * 
  190. 01890 END      .EN  
  191. 01900 * 
  192.  
  193.  
  194.